package net.jcip.vehicles;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class MonitorVehicleTrackerUnmod {
	private final ConcurrentMap<String, ImutablePoint> locations;
	private final Map<String, ImutablePoint> unmodifiableMap;
	
	public MonitorVehicleTrackerUnmod(Map<String,ImutablePoint> data){
		
		locations = new ConcurrentHashMap<String,ImutablePoint>(data);
		unmodifiableMap = Collections.unmodifiableMap(locations);
	}
	
	
	public ImutablePoint getLocation(String name){
		return locations.get(name);
	}
	
	public void setLocation( String name, ImutablePoint point) {
		if (locations.replace(name, point)==null){
			throw new IllegalArgumentException();
		}
		
	}
	
	public Map<String, ImutablePoint> getLocations(){
		return unmodifiableMap;
	}
}
